package com.wkhyapp.lm.weigit.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.wkhyapp.lm.R;


/**
 * Created by fang on 2021/12/2.
 */

public class ExplainDialog {
    private Dialog mDialog;
    private Context mContext;
    private View dialog_view;
    private TextView mbl_tv;
    public ExplainDialog.callBack  mCallBack;

    public ExplainDialog(Context context) {
        this.mContext = context;
        init();
    }

    public void  init(){
        mDialog = new Dialog(mContext, R.style.custom_dialog);
        dialog_view = LayoutInflater.from(mContext).inflate(R.layout.dialog_explain, null);
        mbl_tv = (TextView) dialog_view.findViewById(R.id.mbl_tv);
        mDialog.setContentView(dialog_view);

        Window window = mDialog.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.gravity = Gravity.CENTER; // 居中位置
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);

        mbl_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.jump();
            }
        });
    }

    public void close(){
        mDialog.dismiss();
    }

    public void show(){
        mDialog.show();
    }

    public void setCallBack(ExplainDialog.callBack callBack){
        this.mCallBack = callBack;
    }


    public  interface  callBack{
        void jump();
    }
}
